#!/usr/bin/env bash

pushd $(dirname "$1") > /dev/null
INPUTPATH=$(pwd)/$(basename "$1")
OUTDIR=$(pwd)
popd > /dev/null
SCRIPTPATH=$(dirname "$BASH_SOURCE")
pushd "$SCRIPTPATH" > /dev/null
eval $(cargo run --bin dev-env)
cargo run --bin creusot-rustc --  \
  --edition=2024 \
  -Zno-codegen \
  -Zmacro-backtrace \
  --extern creusot_contracts=./target/creusot/debug/libcreusot_contracts.rlib \
  -Ldependency=./target/creusot/debug/deps/ \
  --crate-type=lib \
  "$INPUTPATH" \
  -- \
  --output-file="${INPUTPATH%.*}.coma" \
  --span-mode=absolute \
  --creusot-extern creusot_contracts=./target/creusot/debug/libcreusot_contracts.cmeta

popd > /dev/null
